<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>预定义常量</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="math.resources.html">« 资源类型</a></li>
      <li style="float: right;"><a href="ref.math.html">Math 函数 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.math.html">Math</a></li>
    <li>预定义常量</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="math.constants" class="appendix">
 <h1>预定义常量</h1>

 <p class="simpara">
下列常量作为 PHP 核心的一部分总是可用的。
</p>
 <p class="para">
  <table class="doctable table">
   <caption><strong>数学常量</strong></caption>
   
    <thead>
     <tr>
      <th>常量</th>
      <th>值</th>
      <th>说明</th>
      <th>有效性</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr id="constant.m-pi">
      <td><strong><code>M_PI</code></strong></td>
      <td>3.14159265358979323846</td>
      <td>Pi</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-e">
      <td><strong><code>M_E</code></strong></td>
      <td>2.7182818284590452354</td>
      <td>e</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-log2e">
      <td><strong><code>M_LOG2E</code></strong></td> 
      <td>1.4426950408889634074</td>
      <td>log_2 e</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-log10e">
      <td><strong><code>M_LOG10E</code></strong></td>
      <td>0.43429448190325182765</td>
      <td>log_10 e</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-ln2">
      <td><strong><code>M_LN2</code></strong></td>   
      <td>0.69314718055994530942</td>
      <td>log_e 2</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-ln10">
      <td><strong><code>M_LN10</code></strong></td>  
      <td>2.30258509299404568402</td>
      <td>log_e 10</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-pi-2">
      <td><strong><code>M_PI_2</code></strong></td>
      <td>1.57079632679489661923</td>
      <td>pi/2</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-pi-4">
      <td><strong><code>M_PI_4</code></strong></td>
     <td>0.78539816339744830962</td>
      <td>pi/4</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-1-pi">
      <td><strong><code>M_1_PI</code></strong></td>
      <td>0.31830988618379067154</td>
      <td>1/pi</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-2-pi">
      <td><strong><code>M_2_PI</code></strong></td>
      <td>0.63661977236758134308</td>
      <td>2/pi</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-sqrtpi">
      <td><strong><code>M_SQRTPI</code></strong></td>    
      <td>1.77245385090551602729</td>
      <td>sqrt(pi)</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-2-sqrtpi">
      <td><strong><code>M_2_SQRTPI</code></strong></td>  
      <td>1.12837916709551257390</td>
      <td>2/sqrt(pi)</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-sqrt2">
      <td><strong><code>M_SQRT2</code></strong></td> 
      <td>1.41421356237309504880</td>
      <td>sqrt(2)</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-sqrt3">
      <td><strong><code>M_SQRT3</code></strong></td> 
      <td>1.73205080756887729352</td>
      <td>sqrt(3)</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-sqrt1-2">
      <td><strong><code>M_SQRT1_2</code></strong></td>   
      <td>0.70710678118654752440</td>
      <td>1/sqrt(2)</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-lnpi">
      <td><strong><code>M_LNPI</code></strong></td>  
      <td>1.14472988584940017414</td>
      <td>log_e(pi)</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.m-euler">
      <td><strong><code>M_EULER</code></strong></td> 
      <td>0.57721566490153286061</td>
      <td>欧拉常数</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.php-round-half-up">
      <td><strong><code>PHP_ROUND_HALF_UP</code></strong></td> 
      <td>1</td>
      <td>Round halves up</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.php-round-half-down">
      <td><strong><code>PHP_ROUND_HALF_DOWN</code></strong></td> 
      <td>2</td>
      <td>Round halves down</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.php-round-half-even">
      <td><strong><code>PHP_ROUND_HALF_EVEN</code></strong></td> 
      <td>3</td>
      <td>四舍五入为偶数</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.php-round-half-odd">
      <td><strong><code>PHP_ROUND_HALF_ODD</code></strong></td> 
      <td>4</td>
      <td>四舍五入为奇数</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.nan">
      <td><strong><code>NAN</code></strong></td>
      <td>NAN (as a float)</td>
      <td>非数值</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr id="constant.inf">
      <td><strong><code>INF</code></strong></td>
      <td>INF (as a float)</td>
      <td>无穷大</td>
      <td class="empty">&nbsp;</td>
     </tr>

    </tbody>
   
  </table>

 </p>
</div>
</div></div></body></html>